﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using UMC.Web.UI;
using UMC.Web;
using UMC.Wiki.Entities;
using System.Collections;

namespace UMC.Wiki.Activities
{



    class SubjectMarkdownActivity : WebActivity
    {
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var webr = UMC.Web.WebResource.Instance();
            var value = this.AsyncDialog("Id", g => this.DialogValue("News"));

            switch (value)
            {
                case "News":
                    response.Redirect(new Subject { Id = UMC.Data.Utility.NewId(), });
                    break;
            }
            var sid = UMC.Data.Utility.UInt64Parse(value, 0);


            var con = DataFactory.Instance().Content(sid) ?? new SubjectContent { Id = sid };

            if (String.Equals("markdown", con.ContentType, StringComparison.CurrentCultureIgnoreCase))
            {
                response.Redirect(new SubjectContent { Id = sid, Content = con.Content });
            }
            else
            {
                response.Redirect(new Subject { Id = sid });
            }


        }

    }
}